package com.ksd.pug.controller.orderhotel;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ksd.pug.service.orderhotel.IOrderHotelService;
import com.ksd.pug.pojo.OrderHotel;
import com.ksd.pug.vo.OrderHotelVo;
import com.ksd.pug.commons.enums.ResultStatusEnumA;
import com.ksd.pug.commons.ex.PugValidationException;
import com.ksd.pug.commons.utils.fn.asserts.Vsserts;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.ksd.pug.controller.BaseController;
import java.util.List;
import java.util.Map;

/**
 * OrderHotelController
 * 创建人:yykk<br/>
 * 时间：2022-05-07 01:38:10 <br/>
 * 源码下载：前台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-ui.git
 * 飞哥B站地址：后台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-parent.git
 * @version 1.0.0<br/>
 *
*/

@RestController
@RequiredArgsConstructor
@Slf4j
public class OrderHotelController extends BaseController{

    private final IOrderHotelService orderhotelService;


    /**
     * 统计订单相关的销售额
     *
     * @return
     */
    @PostMapping("/orderhotel/state/relation")
    public List<Map<String, Object>> countStateOrderRelation() {
        return orderhotelService.countStateOrderRelation();
    }


    /**
     * 查询酒店订单列表信息
     * @path : /admin/orderhotel/load
     * @method: findOrderHotels
     * @result : List<OrderHotel>
     * 创建人:yykk
     * 创建时间：2022-05-07 01:38:10
     * @version 1.0.0
     * @return
     */
    @GetMapping("/orderhotel/load")
    public List<OrderHotel> findOrderHotelList() {
        return orderhotelService.findOrderHotelList();
    }

	/**
	 * 查询酒店订单列表信息并分页
	 * @path : /admin/orderhotel/list
     * @method: findOrderHotels
     * @param : orderhotelVo
     * @result : IPage<OrderHotel>
	 * 创建人:yykk
	 * 创建时间：2022-05-07 01:38:10
	 * @version 1.0.0
	*/
    @PostMapping("/orderhotel/list")
    public IPage<OrderHotel> findOrderHotels(@RequestBody OrderHotelVo orderhotelVo) {
        return orderhotelService.findOrderHotelPage(orderhotelVo);
    }


    /**
     * 根据酒店订单id查询明细信息
     * @method: get/{id}
     * @path : /admin/orderhotel/get/{id}
     * @param : id
     * @result : OrderHotel
     * 创建人:yykk
     * 创建时间：2022-05-07 01:38:10
     * @version 1.0.0
    */
    @GetMapping("/orderhotel/get/{id}")
    public OrderHotel getOrderHotelById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
           throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return orderhotelService.getOrderHotelById(new Long(id));
    }


	/**
	 * 保存和修改酒店订单
     * @method: saveupdate
	 * @path : /admin/orderhotel/save
     * @param : orderhotel
     * @result : OrderHotel
	 * 创建人:yykk
	 * 创建时间：2022-05-07 01:38:10
	 * @version 1.0.0
	*/
    @PostMapping("/orderhotel/saveupdate")
    public OrderHotel saveupdateOrderHotel(@RequestBody OrderHotel orderhotel) {
        return orderhotelService.saveupdateOrderHotel(orderhotel);
    }


    /**
	 * 根据酒店订单id删除酒店订单
     * @method: delete/{id}
     * @path : /admin/orderhotel/delete/{id}
     * @param : id
     * @result : int
	 * 创建人:yykk
	 * 创建时间：2022-05-07 01:38:10
	 * @version 1.0.0
	*/
    @PostMapping("/orderhotel/delete/{id}")
    public int deleteOrderHotelById(@PathVariable("id") String id) {
        if(Vsserts.isEmpty(id)){
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return orderhotelService.deleteOrderHotelById(new Long(id));
    }


   /**
   	 * 根据酒店订单ids批量删除酒店订单
     * @method: orderhotel/delBatch
     * @path : /admin/orderhotel/delBatch
     * @param : orderhotelVo
     * @result : boolean
   	 * 创建人:yykk
   	 * 创建时间：2022-05-07 01:38:10
   	 * @version 1.0.0
   	*/
    @PostMapping("/orderhotel/delBatch")
    public boolean delOrderHotel(@RequestBody OrderHotelVo orderhotelVo) {
        log.info("你要批量删除的IDS是:{}", orderhotelVo.getBatchIds());
        if (Vsserts.isEmpty(orderhotelVo.getBatchIds())) {
            throw new PugValidationException(ResultStatusEnumA.ID_NOT_EMPTY);
        }
        return orderhotelService.delBatchOrderHotel(orderhotelVo.getBatchIds());
    }

}